home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 1 / Gekikoh Dennoh Club Vol. 1 (Japan).7z / Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin / tools / dcv_win / src / dc_main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-02-23  |  68.0 KB  |  2,157 lines

  1. unit Dc_main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Menus, StdCtrls, ShellAPI, ExtCtrls,
  8.   Dc_about, Dc_dlog, Cut_sub, IniFiles;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     OpenDialog1: TOpenDialog;
  13.     MainMenu1: TMainMenu;
  14.     File1: TMenuItem;
  15.     Exit1: TMenuItem;
  16.     N1: TMenuItem;
  17.     PrintSetup1: TMenuItem;
  18.     Print1: TMenuItem;
  19.     N2: TMenuItem;
  20.     Open1: TMenuItem;
  21.     KE1: TMenuItem;
  22.     KG1: TMenuItem;
  23.     K1: TMenuItem;
  24.     KS1: TMenuItem;
  25.     N3: TMenuItem;
  26.     Timer1: TTimer;
  27.     sj1: TMenuItem;
  28.     KD1: TMenuItem;
  29.     KC1: TMenuItem;
  30.     Button1: TButton;
  31.     Button2: TButton;
  32.     Button3: TButton;
  33.     Button4: TButton;
  34.     Button5: TButton;
  35.     Button6: TButton;
  36.     Button7: TButton;
  37.     Panel1: TPanel;
  38.     Label1: TLabel;
  39.     ScrollBar1: TScrollBar;
  40.     Button8: TButton;
  41.     Button9: TButton;
  42.     N4: TMenuItem;
  43.     K2: TMenuItem;
  44.     N11: TMenuItem;
  45.     N21: TMenuItem;
  46.     N31: TMenuItem;
  47.     N41: TMenuItem;
  48.     N51: TMenuItem;
  49.     N61: TMenuItem;
  50.     FontDialog1: TFontDialog;
  51.     KEditer1: TMenuItem;
  52.     FindDialog1: TFindDialog;
  53.     N5: TMenuItem;
  54.     K3: TMenuItem;
  55.     K4: TMenuItem;
  56.     Image1: TImage;
  57.     K5: TMenuItem;
  58.     Panel2: TPanel;
  59.     Label2: TLabel;
  60.     Image2: TImage;
  61.     PrintDialog1: TPrintDialog;
  62.     PrinterSetupDialog1: TPrinterSetupDialog;
  63.     K6: TMenuItem;
  64.     KS2: TMenuItem;
  65.     N6: TMenuItem;
  66.     S1: TMenuItem;
  67.     N1624DotPare1: TMenuItem;
  68.     N1216DotPare1: TMenuItem;
  69.     H1: TMenuItem;
  70.     procedure Open1Click(Sender: TObject);
  71.     procedure Exit1Click(Sender: TObject);
  72.     procedure FormCreate(Sender: TObject);
  73.     procedure Timer1Timer(Sender: TObject);
  74.     procedure Button1Click(Sender: TObject);
  75.     procedure Button2Click(Sender: TObject);
  76.     procedure Button3Click(Sender: TObject);
  77.     procedure Button4Click(Sender: TObject);
  78.     procedure Button8Click(Sender: TObject);
  79.     procedure Button9Click(Sender: TObject);
  80.     procedure Button7Click(Sender: TObject);
  81.     procedure ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
  82.       var ScrollPos: Integer);
  83.     procedure K2Click(Sender: TObject);
  84.     procedure N21Click(Sender: TObject);
  85.     procedure N11Click(Sender: TObject);
  86.     procedure N31Click(Sender: TObject);
  87.     procedure N41Click(Sender: TObject);
  88.     procedure N51Click(Sender: TObject);
  89.     procedure N61Click(Sender: TObject);
  90.     procedure KEditer1Click(Sender: TObject);
  91.     procedure K3Click(Sender: TObject);
  92.     procedure K4Click(Sender: TObject);
  93.     procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
  94.       Shift: TShiftState; X, Y: Integer);
  95.     procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
  96.       Shift: TShiftState; X, Y: Integer);
  97.     procedure K5Click(Sender: TObject);
  98.     procedure Button5Click(Sender: TObject);
  99.     procedure Button6Click(Sender: TObject);
  100.     procedure KS1Click(Sender: TObject);
  101.     procedure KG1Click(Sender: TObject);
  102.     procedure FindDialog1Find(Sender: TObject);
  103.     procedure K1Click(Sender: TObject);
  104.     procedure KS2Click(Sender: TObject);
  105.     procedure N1624DotPare1Click(Sender: TObject);
  106.     procedure N1216DotPare1Click(Sender: TObject);
  107.     procedure KM1Click(Sender: TObject);
  108.     procedure KK1Click(Sender: TObject);
  109.     procedure KH1Click(Sender: TObject);
  110.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  111.     procedure H1Click(Sender: TObject);
  112.   private
  113.     { Private 宣言 }
  114.   public
  115.     { Public 宣言 }
  116.   end;
  117.  
  118. var
  119.   Form1: TForm1;
  120.   isLoad: Integer;
  121.   currentFileName: String;
  122.   currentPath: String;
  123.   currentFileLine: Longint;
  124.   a_Path, b_Path, c_Path: String;
  125.   recordFileName: Array [0..10] of String;
  126.   recordPath: Array [0..10] of String;
  127.   recorddispline: Array [0..10] of Integer;
  128.   depth: Integer;
  129.   mbtn: Integer;
  130.   sFontHight, sFontWidth, lFontHight, lFontWidth: Integer;
  131.   sFontSize, lFontSize: Integer;
  132.   scroll, step: Integer;
  133.   displine: Longint;
  134.   picFlag, edtFlag: Integer;
  135.   picProg, picParam, edtProg, edtParam: String;
  136.   memoDiv: Longint;
  137.   dcvError, useMemo2: integer;
  138.   isBmpCreate: Integer;
  139.   winRc, srcRc1, dstRc1, rgnRc1: TRect;
  140.   srcRc2, dstRc2, rgnRc2: TRect;
  141.   cutBmpArray: Array [0..40] of TBitMap;
  142.   cutExe: Array [0..40] of Integer;
  143.   cutNo: Integer;
  144.   dispCut: Integer;
  145.   txtHdl: THandle;
  146.   dcLine: Array [0..9999] of Pointer;
  147.   dcSize: Longint;
  148.   pastline: Longint;
  149.   dcBmp: TBitMap;
  150.   dcBmpOk: Integer;
  151.   slFontType: String;
  152.   FontSize: Integer;
  153.   ownPath: String;
  154.   function loadText(name: String):Boolean;
  155.   function drawText(dispLine: Longint; dmode: Integer): boolean;
  156.   function pickupPath(name: String): Boolean;
  157.   function nextFile(comline, nextFileName: String): boolean;
  158.   function changePath(name: String): String;
  159.   function structName(name: String): String;
  160.   function returnDoc(dispmode: Integer): Boolean;
  161.   function escChange(escCode: Integer): Boolean;
  162.   function setConditions(escCode: Integer): Boolean;
  163.   function setCondition2(escCode2: Integer): Boolean;
  164.   function fock(fockFileName, Params, DefaultDir: String): Integer;
  165.   function isKanji(ck: Char): Integer;
  166.   function isKigou(cc: Char): Integer;
  167.   function isExcept(ce: String): Integer;
  168.   function findTextDown(sTxt: String): Boolean;
  169.   function findTextUp(sTxt: String): Boolean;
  170.   function drawSLine(ll: Longint): Boolean;
  171.   function SetIni(ini: String): Boolean;
  172.   function CheckScroll(qc:Integer): Boolean;
  173.   function SetLargeFont(FS1:Integer):Boolean;
  174.   function SetSmallFont(FS2:Integer):Boolean;
  175.   implementation
  176.  
  177. {$R *.DFM}
  178.  
  179. procedure TForm1.Open1Click(Sender: TObject);
  180. begin
  181.      if OpenDialog1.Execute then
  182.         begin
  183.              { FileOpenDialog }
  184.              currentFileName := OpenDialog1.FileName;
  185.              loadText(currentFileName);
  186.              if (dcvError>0) then
  187.              begin
  188.                   dcvError := 0;
  189.                   exit;
  190.              end;
  191.              drawText(displine, 0);
  192.         end;
  193. end;
  194.  
  195. function loadText(name: String):Boolean;
  196. var
  197.    exbuff: Array [1..2048] of char;
  198.    buff: Array [1..4] of String[255];
  199.    ori, dpos, cpos, jpos, cutSubNo: Integer;
  200.    fl, blen, gyou, retu, ret, fileHdl: Longint;
  201.    cf: file of byte;
  202.    theLine: String;
  203.    theChar: Char;
  204.    memoCount, memo2Flag, cfl: Longint;
  205.    sbuff, sbuf2, cutName: String;
  206.  
  207.    dmyPtr: PChar;
  208.    dmyHdl: THandle;
  209.    txtPt, txtTop, txtRes, txtBuf: PChar;
  210.    i, ii, j, jj, line_count: Longint;
  211.    vw, txt_end, zen, tb, esc, err, cutOk, pgb, barMax, fpos: Integer;
  212.    cut_lno: Char;
  213.    fbuff, fbuff2, dmyfname: String;
  214.    pat1, msg: String;
  215.    barRc: TRect;
  216. begin
  217.      { Save CurrentPath }
  218.      currentPath := ExtractFilePath(currentFileName);
  219.      if (AnsiUpperCase(ExtractFileName(currentFileName)) = 'MOKUJI.DOC') then
  220.              pickupPath(currentFileName);
  221.      { Disable MainForm } {
  222.      form1.enabled := False;  }
  223.      { CheckName }
  224.      currentFileName := AnsiUpperCase(currentFileName);
  225.      currentFileName := AnsiUpperCase(currentFileName);
  226.      fbuff := ExtractFileName(currentFileName);
  227.      if (Length(fbuff) > 12) then
  228.      begin
  229.           fpos := Pos('.', fbuff);
  230.           if (fpos > 0) then
  231.           begin
  232.                fbuff2 := Copy(fbuff, 1, 8);
  233.                fbuff := fbuff2 + Copy(fbuff, fpos, 4);
  234.                fbuff2 := ExtractFilePath(currentFileName);
  235.                currentFileName := fbuff2 + fbuff;
  236.           end;
  237.      end;
  238.      { File is There? }
  239.      if FileExists(currentFileName) = False then
  240.      begin
  241.           msg := '"' + currentFileName + '"' + 'が見つかりません!';
  242.           MessageDlg(msg, mtError, [mbOK], 0);
  243.           dcvError := 1;
  244.           { Enable MainForm }
  245.           form1.enabled := True;
  246.           exit;
  247.      end;
  248.      { Iregal FileType }
  249.      if (ExtractFileExt(currentFileName) = '.X')
  250.       Or (ExtractFileExt(currentFileName) = '.Z')
  251.        Or (ExtractFileExt(currentFileName) = '.R')
  252.         Or (ExtractFileExt(currentFileName) = '.EXE')
  253.          Or (ExtractFileExt(currentFileName) = '.COM') then
  254.      begin
  255.           msg := '"' + currentFileName + '"' + 'このファイルは読み込めません!';
  256.           MessageDlg(msg, mtError, [mbOK], 0);
  257.           dcvError := 1;
  258.           { Enable MainForm }
  259.           form1.enabled := True;
  260.           exit;
  261.      end;
  262.      { Iregal FileName}
  263.      theline := ExtractFileName(currentFileName);
  264.      if (Length(ExtractFileName(currentFileName)) > 12) then
  265.      begin
  266.           msg := '"' + currentFileName + '"' + 'ファイル名が異常です!';
  267.           MessageDlg(msg, mtError, [mbOK], 0);
  268.           dcvError := 1;
  269.           { Enable MainForm }
  270.           form1.enabled := True;
  271.          exit;
  272.      end;
  273.      { Reset Values }
  274.      memoCount := 0;
  275.      displine := 0;
  276.      currentFileLine := 0;
  277.      AssignFile(cf, currentFileName);
  278.      FileMode := 0;
  279.      Reset(cf);
  280.      fl := FileSize(cf);
  281.      Close(cf);
  282.      { FileSize Too Large? }
  283.      if (fl >  2*1024*1024) then
  284.      begin
  285.           MessageDlg('ファイルサイズが大きすぎます!', mtError, [mbOK], 0);
  286.           dcvError := 1;
  287.           { Enable MainForm }
  288.           form1.enabled := True;
  289.           exit;
  290.      end;
  291.      dcSize := fl;
  292.      dmyHdl := GlobalAlloc(GMEM_DISCARDABLE+GMEM_MOVEABLE+GMEM_ZEROINIT, fl + 1024);
  293.      if (dmyHdl = 0) then
  294.      begin
  295.           MessageDlg('メモリが確保できません!', mtError, [mbOK], 0);
  296.           dcvError := 1;
  297.           { Enable MainForm }
  298.           form1.enabled := True;
  299.           exit;
  300.      end;
  301.      GlobalFree(dmyHdl);
  302.      { Get GlobalMemory }
  303.      if (isLoad = 1) then
  304.         GlobalFree(txtHdl);
  305.      txtHdl := GlobalAlloc(GMEM_DISCARDABLE+GMEM_MOVEABLE+GMEM_ZEROINIT, fl + 1024);
  306.      { Set Cursor crHourGlass }
  307.      screen.cursor := crHourGlass;
  308.      { Disable Control }
  309.      form1.File1.Enabled := False;
  310.      form1.KE1.Enabled := False;
  311.      form1.K6.Enabled := False;
  312.      form1.sj1.Enabled := False;
  313.      form1.button1.enabled := False;
  314.      form1.button2.enabled := False;
  315.      form1.button3.enabled := False;
  316.      form1.button4.enabled := False;
  317.      form1.button5.enabled := False;
  318.      form1.button6.enabled := False;
  319.      form1.button8.enabled := False;
  320.      form1.button9.enabled := False;
  321.      form1.scrollbar1.enabled := False;
  322.      form1.KE1.enabled := False;
  323.      form1.KEditer1.enabled := False;
  324.      form1.H1.enabled := False;
  325.      if (depth > 0) then
  326.           form1.button7.enabled := False;
  327.      { LockGlobalBlock }
  328.      txtPt := GlobalLock(txtHdl);
  329.      txtRes := txtPt;
  330.      txtTop := txtPt;
  331.      { Read File To txtHdl }
  332.      fileHdl := FileOpen(currentFileName, OF_SHARE_COMPAT);
  333.      FileRead(fileHdl, txtPt^, fl);
  334.      FileClose(fileHdl);
  335.      { Count LineNumber }
  336.      currentFileLine := 0;
  337.      line_count := 1;
  338.      cutNo := 0;
  339.      pgb := 0;
  340.      while (1=1) do
  341.      begin
  342.           j := 0;
  343.             jj := 0;
  344.           vw := 0;
  345.            dcLine[line_count] := Pointer(Longint(txtPt) - Longint(txtTop));
  346.           txt_end := 0;
  347.           zen := 1;
  348.           while (1=1) do
  349.           begin
  350.                if (txtPt^ = Chr(26)) Or (txtPt^ = Chr(0)) then    { EOF }
  351.                begin
  352.                     txtPt^ := Chr(0);
  353.                     txt_end := 1;
  354.                     break;
  355.                end;
  356.  
  357.                if (txtPt^ = Chr(13)) then                         { 改行処理 }
  358.                begin
  359.                     Inc(txtPt, 1);
  360.                     break;
  361.                end;
  362.  
  363.                if (txtPt^ = Chr(10)) then                         { LF処理 }
  364.                begin
  365.                     Inc(txtPt, 1);
  366.                        dcLine[line_count] := Pointer(Longint(txtPt) - Longint(txtTop));
  367.                     continue;
  368.                   end;
  369.  
  370.                if (txtPt^ = Chr(9)) then                          { TAB処理 }
  371.                begin
  372.                     tb := 8 - (jj Mod 8);
  373.                     j := 0;
  374.                     jj := jj + tb;
  375.                     Inc(txtPt, 1);
  376.                     zen := 0;
  377.                     continue;
  378.                end;
  379.  
  380.                if (txtPt^ =  Chr(27)) then                        { esc文字属性 }
  381.                begin
  382.                     if ((txtPt+1)^ = '[') then
  383.                     begin
  384.                        esc := 0;
  385.                        txtPt := txtPt + 2;
  386.                        while (txtPt^ <> 'm') do
  387.                              Inc(txtPt, 1);
  388.                        Inc(txtPt, 1);
  389.                        continue;
  390.                     end;
  391.                end;
  392.  
  393.                if (jj = 94) then                                  { 行の折り返し }
  394.                begin
  395.                     pat1 :='';
  396.                     pat1 := txtPt^;
  397.                     pat1 := pat1 + (txtPt + 1)^;
  398.                     if (isExcept(pat1) = 1) then
  399.                     begin
  400.                           Inc(txtPt, 2);
  401.                        if (txtPt^ = Chr(13)) then
  402.                        begin
  403.                             Inc(txtPt, 1);
  404.                             break;
  405.                        end;
  406.                     end;
  407.                 end;
  408.  
  409.                 if (jj > 94) then
  410.                        break;
  411.  
  412.                 if (isKanji(txtPt^) = 1) then                     { 漢字 }
  413.                 begin
  414.                     Inc(txtPt, 2);
  415.                     Inc(jj, 2);
  416.                     continue;
  417.                 end;
  418.  
  419.                 if (txtPt^ =  '%') then                           { %コード処理 }
  420.                 begin
  421.                      if ((txtPt + 1)^ = 'V') then                 { 倍角設定 }
  422.                      begin
  423.                         vw := 1;
  424.                         Inc(txtPt, 4);
  425.                         j := 0;
  426.                         continue;
  427.                      end;
  428.  
  429.                      if ((txtPt + 1)^ = 'C') And (dispCut = 1) And (cutNo < 30) then
  430.                      begin
  431.                   if ((txtPt + 4)^ = ':') then           { カットファイル }
  432.                           begin
  433.                                { Show ProgressBar }
  434.                                if (pgb = 0) then
  435.                                begin
  436.                                   barRc := Rect(0, 0, 233, 17);
  437.                                   barMax := fl div 10;
  438.                                   form1.panel2.visible := True;
  439.                                   form1.image2.canvas.brush.Color := clBlack;
  440.                                   form1.image2.canvas.FrameRect(barRc);
  441.                                   form1.image2.canvas.brush.Color := clWhite;
  442.                                   barRc := Rect(1, 1, 233-1, 17-1);
  443.                                   form1.image2.canvas.FillRect(barRc);
  444.                                   form1.image2.canvas.brush.Color := clBlue;
  445.                                  pgb := 1;
  446.                                end;
  447.                                txtBuf := txtPt;
  448.                                Inc(cutNo, 1);
  449.                                cut_lno := '1';
  450.                                (txtPt+2)^ := Chr(Ord('0') + cutNo);
  451.                                (txtPt+3)^ := cut_lno;
  452.                                Inc(txtPt, 5);
  453.                                while (isKigou(txtPt^) = 1) do
  454.                                    Inc(txtPt, 1);
  455.                                dmyfname := '';
  456.                                for i:=0 to 90-1 do
  457.                                begin
  458.                                     if (txtPt^ = '.') then
  459.                                        break;
  460.                                     dmyfname := dmyfname + txtPt^;
  461.                                     Inc(txtPt, 1);
  462.                                end;
  463.                                for ii:=i to i+3 do
  464.                                begin
  465.                                   dmyfname := dmyfname + txtPt^;
  466.                                   Inc(txtPt, 1);
  467.                                end;
  468.                                cutName := structName(dmyfname);
  469.                                { Get Bitmap }
  470.                                if (cutExe[cutNo] = 1) then cutBmpArray[cutNo].free;
  471.                                cutBmpArray[cutNo] := TBitmap.create;
  472.                                cutExe[cutNo] := cut_sub.cutSub(cutName, cutBmpArray[cutNo]);
  473.                                err := cutExe[cutNo];
  474.                                if (err = 0) then
  475.                                begin
  476.                                     cutOk := 0;
  477.                                     txtPt := txtBuf;
  478.                                     (txtPt+2)^ := 'U';
  479.                                     (txtPt+3)^ := 'T';
  480.                                end;
  481.                                if (err = 1) then
  482.                                begin
  483.                                     cutOk := 1;
  484.                                     continue;
  485.                                end;
  486.                           end;
  487.                           if (cutOk = 1) then
  488.                           begin
  489.                                (txtPt+2)^ := Chr(Ord('0') + cutNo);
  490.                                Inc(cut_lno, 1);
  491.                                (txtPt+3)^ := cut_lno;
  492.                           end;
  493.                      end;
  494.                 end;
  495.  
  496.                 if (txtPt^ =  Chr(24)) then                  { 倍角解除 }
  497.                 begin
  498.                        if (vw = 1) then
  499.                      begin
  500.                            vw := 0;
  501.                           j := 0;
  502.                           continue;
  503.                      end;
  504.                        Inc(txtPt, 1);
  505.                      continue;
  506.                end;
  507.  
  508.                Inc(txtPt, 1);                                { Normal String }
  509.                Inc(jj ,1);
  510.           end;
  511.           if (txt_end = 1) then break;
  512.           if ((Longint(txtPt) - Longint(txtTop) + 1) >= fl) then break;
  513.           Inc(line_count, 1);
  514.           { Do ProgressBar }
  515.           if (pgb > 0) then
  516.           begin
  517.                barRc.Right := 3 + (23 *(Longint(txtPt) - Longint(txtTop) + 1)) div barmax;
  518.                form1.image2.canvas.FillRect(barRc);
  519.           end;
  520.           Application.ProcessMessages;
  521.      end;
  522.      { Del ProgressBar }
  523.      if (pgb > 0) then
  524.      begin
  525.           form1.panel2.visible := False;
  526.      end;
  527.      currentFileLine := line_count;
  528.      { Replace WindowTitle }
  529.      form1.Caption :='DC_VIEW ['+ExtractFileName(currentFileName)+']';
  530.      form1.scrollbar1.position := 0;
  531.      if (currentFileLine - 30 < 0) then
  532.         form1.scrollbar1.max := 0
  533.      else
  534.         form1.scrollbar1.max := currentFileLine - 30;
  535.      { File Loaded }
  536.      isLoad := 1;
  537.      { Enable Control }
  538.      form1.File1.Enabled := True;
  539.      form1.KE1.Enabled := True;
  540.      form1.K6.Enabled := True;
  541.      form1.sj1.Enabled := True;
  542.      form1.button1.enabled := True;
  543.      form1.button2.enabled := True;
  544.      form1.button3.enabled := True;
  545.      form1.button4.enabled := True;
  546.      form1.button5.enabled := True;
  547.      form1.button6.enabled := True;
  548.      form1.button8.enabled := True;
  549.      form1.button9.enabled := True;
  550.      form1.scrollbar1.enabled := True;
  551.      form1.KE1.enabled := True;
  552.      form1.KEditer1.enabled := True;
  553.      form1.H1.enabled := True;
  554.      if (depth > 0) then
  555.           form1.button7.enabled := True;
  556.      { UnlockGlobalBlock }
  557.      GlobalUnlock(txtHdl);
  558.      { Enable MainForm }       {
  559.      form1.enabled := True;   }
  560. end;
  561.  
  562. procedure TForm1.Exit1Click(Sender: TObject);
  563. var
  564.    i: Integer;
  565. begin
  566.     if (isLoad = 1) then
  567.         GlobalFree(txtHdl);
  568.     for i:=1 to 40 do
  569.     begin
  570.          if (cutExe[i] = 1) then
  571.             cutBmpArray[i].Free;
  572.     end;
  573.     close;
  574. end;
  575.  
  576. function drawText(dispLine: Longint; dmode: Integer): boolean;
  577. var      buff, buff2, buff3: String;
  578.          moji: Char;
  579.          dcutNo, dcutRc: Integer;
  580.          i, j, k, l, done, spos, lpos, x, y, sl, el, esc, tmp, linelen, dmyLen: Integer;
  581.          cutToRc, cutFrRc: Trect;
  582.  
  583.          jj, vw, zen, tb, istop: Integer;
  584.          txtPt : PChar;
  585.          lineBuff: PChar;
  586.          pat1: String;
  587. begin
  588.     { Get LineBuffer Memory }
  589.     GetMem(lineBuff, 256);
  590.     { File Already Loaded? }
  591.     if isLoad = 0 then exit;
  592.     { Disp AllLines }
  593.     if (dmode = 0) then
  594.     begin
  595.         form1.image1.canvas.FillRect(winRc);
  596.         sl :=  0;
  597.         el := 30;
  598.     end;
  599.     { Disp Scroll }
  600.     if (dmode <> 0) then
  601.     begin
  602.         if (scroll = 1) then
  603.         begin
  604.             sl := 30 - step - 1;
  605.             el := 30;
  606.             form1.image1.canvas.CopyRect(dstRc1, form1.image1.canvas, srcRc1);
  607.             form1.image1.canvas.FillRect(rgnRc1);
  608.         end;
  609.         if (scroll = -1) then
  610.         begin
  611.             sl :=  0;
  612.             el :=  step + 1;
  613.             form1.image1.canvas.CopyRect(dstRc2, form1.image1.canvas, srcRc2);
  614.             form1.image1.canvas.FillRect(rgnRc2);
  615.         end;
  616.     end;
  617.     { LockGlobalBlock }
  618.     txtPt := GlobalLock(txtHdl);
  619.     txtPt := Pointer(Longint(txtPt) + Longint(dcLine[displine+sl+1]));
  620.     { Draw Lines }
  621.     for i:=sl to el do
  622.     begin
  623.              if (currentFileLine < (displine + i)) then break;
  624.              j := 0;
  625.              jj := 0;
  626.              vw := 0;
  627.              zen := 1;
  628.              x := 0;
  629.              y := i * sFontHight;
  630.              while (1=1) do
  631.              begin
  632.                 if (txtPt^ = Chr(13)) then                    { 改行処理 }
  633.                 begin
  634.                     lineBuff[j] := Chr(0);
  635.                     Inc(txtPt, 1);
  636.                     break;
  637.                 end;
  638.  
  639.                 if (txtPt^ = Chr(10)) then            { LF処理   }
  640.                 begin
  641.                     Inc(txtPt, 1);
  642.                     continue;
  643.                 end;
  644.  
  645.                 if (txtPt^ = Chr(9)) then                  { TAB処理 }
  646.                  begin
  647.                       tb := 8 - (jj Mod 8);
  648.                       lineBuff[j] := Chr(0);
  649.                       if (j > 0) then
  650.                        form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  651.                     Inc(x, (tb  + Strlen(lineBuff)) * sFontWidth);
  652.                     
  653.                       j := 0;
  654.                       jj := jj + tb;
  655.                       Inc(txtPt, 1);
  656.                       zen := 0;
  657.                       continue;
  658.                    end;
  659.  
  660.                  if (txtPt^ =  Chr(27)) then            { esc文字属性 }
  661.                  begin
  662.                     if ((txtPt+1)^ = '[') then
  663.                     begin
  664.                          buff2 := '';
  665.                          esc := 0;
  666.                          Inc(txtPt, 2);
  667.                          while ((txtPt^ <> 'm') And (txtPt^ <> 'C')) do
  668.                          begin
  669.                               buff2:= buff2 + txtPt^;
  670.                             Inc(esc, 1);
  671.                             Inc(txtPt, 1);
  672.                          end;
  673.  
  674.                          if (esc <> 0) then                     { esc設定 }
  675.                          begin
  676.                               if (txtPt^ = 'C') then         { Incert Spaxce }
  677.                               begin
  678.                                     esc := StrToInt(buff2);
  679.                                  Inc(x, esc * sFontWidth);
  680.                                     Inc(txtPt, 1);
  681.                                     j := 0;
  682.                                     continue;
  683.                               end;
  684.                               esc := StrToInt(buff2);
  685.                               lineBuff[j] := Chr(0);
  686.                               form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  687.                             Inc(x, Strlen(lineBuff) * sFontWidth);
  688.  
  689.                               escChange(esc);
  690.  
  691.                               Inc(txtPt, 1);
  692.                               j := 0;
  693.                               continue;
  694.                         end;
  695.  
  696.                          if (esc = 0) then
  697.                          begin
  698.                               lineBuff[j] := Char(0);
  699.                               form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  700.                             Inc(x, Strlen(lineBuff) * sFontWidth);
  701.  
  702.                               escChange(33);
  703.  
  704.                               Inc(txtPt, 1);
  705.                               j := 0;
  706.                               continue;
  707.                          end;
  708.                     end;
  709.                  end;
  710.  
  711.                  if (jj = 94) then                    { 行の折り返し }
  712.                  begin
  713.                     pat1 := '';
  714.                     pat1 := pat1 + txtPt^;
  715.                     pat1 := pat1 + (txtPt+1)^;
  716.                       if (isExcept(pat1) = 1) then
  717.                       begin
  718.                            lineBuff[j] := txtPt^;
  719.                         Inc(j, 1);
  720.                         Inc(txtPt, 1);
  721.                            lineBuff[j] := txtPt^;
  722.                         Inc(j, 1);
  723.                         Inc(txtPt, 1);
  724.                       end;
  725.                       if (txtPt^ = Chr(13)) then
  726.                            Inc(txtPt, 1);
  727.                     lineBuff[j] := Chr(0);
  728.                     break;
  729.                 end;
  730.  
  731.                 if (jj > 94) then
  732.                 begin
  733.                      lineBuff[j] := Chr(0);
  734.                      break;
  735.                   end;
  736.  
  737.                  if (isKanji(txtPt^) = 1) then             { 漢字 }
  738.                  begin
  739.                       lineBuff[j] := txtPt^;
  740.                     Inc(txtPt, 1);
  741.                     Inc(j, 1);
  742.                       lineBuff[j] := txtPt^;
  743.                     Inc(txtPt, 1);
  744.                     Inc(j, 1);
  745.                       Inc(jj, 2);
  746.                       continue;
  747.                  end;
  748.  
  749.                  if (txtPt^ =  '%') then                 { %コード処理 }
  750.                  begin
  751.                       if ((txtPt + 1)^ = 'V') then    { 倍角設定 }
  752.                       begin
  753.                            vw := 1;
  754.                            Inc(txtPt, 4);
  755.                            lineBuff[j] := Chr(0);
  756.                            form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  757.                         Inc(x, Strlen(lineBuff) * sFontWidth);
  758.                         
  759.                            j := 0;
  760.                            continue;
  761.                       end;
  762.                       if (((txtPt + 1)^ = 'C') And ((txtPt+2)^ <> 'U')) then
  763.                       begin                            { カットファイル }
  764.                            dcutNo := Ord((txtPt+2)^) - 48;
  765.                            dcutRc := Ord((txtPt+3)^) - 49;
  766.                         istop := 0;
  767.                            if ((txtPt+4)^ = ':') then
  768.                            begin
  769.                             while (txtPt^ <> '.') do
  770.                                  Inc(txtPt, 1);
  771.                             Inc(txtPt, 4);
  772.                             istop := 1;
  773.                            end;
  774.                            if (istop = 0) then
  775.                           begin
  776.                             Inc(txtPt, 4);
  777.                            end;
  778.                            if (j>0) then
  779.                            begin
  780.                             lineBuff[j] := Chr(0);
  781.                                form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  782.                             Inc(x, Strlen(lineBuff) * sFontWidth);
  783.                             
  784.                             j := 0;
  785.                            end;
  786.                         { Draw CutFile }
  787.                         if ((dcutRc + 1) * 16 > cutBmpArray[dcutNo].Height) then
  788.                         begin
  789.                              cutFrRc := Rect(0, dcutRc * 16, cutBmpArray[dcutNo].Width, cutBmpArray[dcutNo].Height);
  790.                              cutToRc := Rect(x, y, x + (cutBmpArray[dcutNo].Width * sFontWidth) Div 8,
  791.                                y + ((cutBmpArray[dcutNo].Height - dcutRc * 16 + 1) * sFontWidth) Div 8);
  792.                         end;
  793.                         if ((dcutRc + 1) * 16 <= cutBmpArray[dcutNo].Height) then
  794.                         begin
  795.                              cutFrRc := Rect(0, dcutRc * 16, cutBmpArray[dcutNo].Width, (dcutRc + 1) * 16);
  796.                              cutToRc := Rect(x, y, x + (cutBmpArray[dcutNo].Width * sFontWidth) Div 8, y + sFontHight);
  797.                         end;
  798.                         form1.image1.canvas.CopyRect(cutToRc, cutBmpArray[dcutNo].canvas, cutFrRc);
  799.                         Inc(x, (cutBmpArray[dcutNo].Width * sFontWidth) Div 8);
  800.                         continue;
  801.                       end;
  802.                  end;
  803.  
  804.                  if (txtPt^ =  Chr(24)) then                    { 倍角解除 }
  805.                  begin
  806.                       if (vw = 1) then
  807.                       begin
  808.                            lineBuff[j] := Chr(0);
  809.                         form1.image1.canvas.Font.Size := lFontSize;
  810.                         y := y + 4;
  811.  
  812.                            form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  813.                         Inc(x, Strlen(lineBuff) * sFontWidth);
  814.                         
  815.  
  816.                         form1.image1.canvas.Font.Size := sFontSize;
  817.                         y := y - 4;
  818.  
  819.                            vw := 0;
  820.                            jj := jj + j Div 2;
  821.                         Inc(x, (j Div 2) * sFontWidth);
  822.  
  823.                            j := 0;
  824.                            Inc(txtPt, 1);
  825.                            continue;
  826.                       end;
  827.                       Inc(txtPt, 1);
  828.                       continue;
  829.                  end;
  830.  
  831.                  lineBuff[j] := txtPt^;
  832.                 Inc(j, 1);
  833.                 Inc(txtPt,1);
  834.                  lineBuff[j] := Chr(0);
  835.  
  836.                  Inc(jj, 1);
  837.             end;
  838.  
  839.             if (vw = 1) then
  840.             begin
  841.                  form1.image1.canvas.Font.Size := lFontSize;
  842.                  y := y + 4;
  843.             end;
  844.             form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
  845.             Inc(x, Strlen(lineBuff) * sFontWidth);
  846.             if (vw = 1) then
  847.             begin
  848.                  form1.image1.canvas.Font.Size := sFontSize;
  849.                  y := y - 4;
  850.                   vw := 0;
  851.             end;
  852.             esc := 33;
  853.             escChange(esc);
  854.       end;
  855.     { UnlockGlobalBlock }
  856.     GlobalUnlock(txtHdl);
  857.     { Free LineBffer Memory }
  858.     FreeMem(lineBuff, 256);
  859.     { Set ScrollBar & DisplayPosition }
  860.     form1.scrollbar1.position := displine;
  861.     Str(displine, buff);
  862.     buff2 := '';
  863.     for i:=1 to 5-Length(buff) do
  864.         buff2 := buff2 + ' ';
  865.     buff2 := buff2 + buff;
  866.     form1.label1.caption := buff2;
  867.     { Set Cursor crHourGlass }
  868.     screen.cursor := crArrow;
  869. end;
  870.  
  871. function escChange(escCode: Integer): Boolean;
  872. var
  873.    escColor, fc: Integer;
  874. begin
  875.      { Change FontColor }
  876.      escColor := (escCode Mod 10) Mod 4;
  877.      case escColor of
  878.      0: form1.image1.canvas.font.color := clGreen;
  879.      1: form1.image1.canvas.font.color := clAqua;
  880.      2: form1.image1.canvas.font.color := clFuchsia;
  881.      3: form1.image1.canvas.font.color := clWhite;
  882.      end;
  883.      { Change FontStyle }
  884.      if escCode < 34 then
  885.      begin
  886.           form1.image1.canvas.Font.Style := [];
  887.           form1.image1.canvas.Font.Size := sFontSize;
  888.           exit;
  889.      end;
  890.      if escCode < 38 then
  891.      begin
  892.           form1.image1.canvas.Font.Style := [fsBold];
  893.           form1.image1.canvas.Font.Size := sFontSize - 1;
  894.           exit;
  895.      end;
  896.      if escCode < 44 then
  897.      begin
  898.           form1.image1.canvas.Font.Style := [fsItalic];
  899.           form1.image1.canvas.Font.Size := sFontSize;
  900.           exit;
  901.      end;
  902.      if escCode >= 44 then
  903.      begin
  904.           form1.image1.canvas.Font.Style := [fsBold]+[fsItalic];
  905.           form1.image1.canvas.Font.Size := sFontSize - 1;
  906.      end;
  907. end;
  908.  
  909. function setConditions(escCode: Integer): Boolean;
  910. begin
  911.      form1.image1.canvas.Font.Size := sFontSize;
  912.      form1.image1.canvas.brush.color := clGreen;
  913.      form1.image1.canvas.font.color := clWhite;
  914.      form1.image1.canvas.Font.Style := [];
  915. end;
  916. function setCondition2(escCode2: Integer): Boolean;
  917. begin
  918.      srcRc1 := Rect(0, step*sFontHight, form1.clientwidth, form1.clientheight-18);
  919.      dstRc1 := Rect(0, 0, form1.clientwidth, form1.clientheight-18-step*sFontHight);
  920.      rgnRc1 := Rect(0, form1.clientheight-18-step*sFontHight, form1.clientwidth, form1.clientheight-18);
  921.      srcRc2 := Rect(0, 0, form1.clientwidth,form1.clientheight-18-step*sFontHight);
  922.      dstRc2 := Rect(0, step*sFontHight, form1.clientwidth,form1.clientheight-18);
  923.      rgnRc2 := Rect(0, 0, form1.clientwidth, step*sFontHight);
  924. end;
  925.  
  926. function pickupPath(name: String): Boolean;
  927. var
  928.    dpos, dpos1, dpos2: Integer;
  929.    buff, buff2: String;
  930. begin
  931.    buff := ExtractFilePath(currentFileName);
  932.    buff2 := '';
  933.    { Search Directory }
  934.    dpos1 := Pos('QS', buff);
  935.    if (dpos1 > 0) then
  936.         buff2 := Copy(buff, 1, dpos1 - 1);
  937.    dpos2 := Pos('QUICKSTA', buff);
  938.    if (dpos2 > 0) then
  939.         buff2 := Copy(buff, 1, dpos2 - 1);
  940.    if (dpos1 = 0) And (dpos2 = 0) then buff2 := buff;
  941.    a_Path := Copy(buff2, 1, Length(buff2) - 1);
  942.    { B,C Path Setting }
  943.    dpos :=Pos('A\', buff2);
  944.    if (dpos > 0) then
  945.    begin
  946.         buff2[dpos] := 'B';
  947.         b_Path := Copy(buff2, 1, Length(buff2) - 1);
  948.         dpos :=Pos('B\', buff2);
  949.         buff2[dpos] := 'C';
  950.         c_Path := Copy(buff2, 1, Length(buff2) - 1);
  951.         exit;
  952.    end;
  953.    dpos :=Pos('1\', buff2);
  954.    if (dpos > 0) then
  955.    begin
  956.         buff2[dpos] := '2';
  957.         b_Path := Copy(buff2, 1, Length(buff2) - 1);
  958.         dpos :=Pos('2\', buff2);
  959.         buff2[dpos] := '3';
  960.         c_Path := Copy(buff2, 1, Length(buff2) - 1);
  961.    end;
  962. end;
  963.  
  964. function nextFile(comline, nextFileName: String): boolean;
  965. var
  966.    buff, buff2, buff3, buffPath: String;
  967.    docName, exeName, pathName: String;
  968.    dpos, epos, i, j: Integer;
  969.    comPos, execFlag: Integer;
  970. begin
  971.    buff := Copy(comline, 1, 2);
  972.    { Comannd Exist? }
  973.    if (CompareText(buff, '◎') = 0) then
  974.    begin
  975.         { PickUp Command }
  976.         comPos := Pos('TYPE=', comline);
  977.         if (comPos = 0) then exit;
  978.         buff2 := Copy(comline, comPos, Length(comline) - comPos + 1);
  979.         { Select Type }
  980.         buff3 := Copy(Buff2, 6, 3);
  981.         if (CompareText(buff3, 'DCV') = 0) then
  982.         { Load NextFileName }
  983.         begin
  984.            { Push CurrentFile }
  985.            recordFileName[depth] := currentFileName;
  986.            recorddispline[depth] := displine;
  987.            recordPath[depth] := currentPath;
  988.            depth := depth + 1;
  989.            { Get NextFile & Draw It }
  990.            buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
  991.            for j:=1 to 3 do
  992.            begin
  993.                if (isKigou(buff[j]) = 1) then
  994.                    Inc(i, 1)
  995.                else
  996.                    break;
  997.            end;
  998.            if (j <> 1) then
  999.               buff := Copy(buff, j, length(buff) - j + 1);
  1000.            currentFileName := buff;
  1001.            loadText(currentFileName);
  1002.            if (dcvError>0) then
  1003.            begin
  1004.                 dcvError := 0;
  1005.                 returnDoc(0);
  1006.                 exit;
  1007.            end;
  1008.            drawText(displine, 0);
  1009.            exit;
  1010.         end;
  1011.  
  1012.         if (CompareText(buff3, 'DOC') = 0) then
  1013.         { Load NextFileName }
  1014.         begin
  1015.            { Push CurrentFile }
  1016.            recordFileName[depth] := currentFileName;
  1017.            recorddispline[depth] := displine;
  1018.            recordPath[depth] := currentPath;
  1019.            depth := depth + 1;
  1020.            { Get NextFile & Draw It }
  1021.            buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
  1022.            currentFileName := structName(buff);
  1023.            loadText(currentFileName);
  1024.            if (dcvError>0) then
  1025.            begin
  1026.                 dcvError := 0;
  1027.                 returnDoc(0);
  1028.                 exit;
  1029.            end;
  1030.            drawText(displine, 0);
  1031.            exit;
  1032.         end;
  1033.  
  1034.         if (CompareText(buff3, 'EDE') = 0) then
  1035.         { Execute PictureLoad & Load NextFile }
  1036.         begin
  1037.              { Push CurrentFile }
  1038.              recordFileName[depth] := currentFileName;
  1039.              recorddispline[depth] := displine;
  1040.              recordPath[depth] := currentPath;
  1041.              depth := depth + 1;
  1042.              buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
  1043.              { Get DocFileName }
  1044.              buff3 := '';
  1045.              dpos := 1;
  1046.              if (buff[1] = 'C') And (buff[2] = 'D')
  1047.                And ((buff[3] = ' ') Or (buff[3] = '=')) then
  1048.              begin
  1049.                   buff2 := Copy(buff, 4, Length(buff) - 4 + 1);
  1050.                   for i:=1 to Length(buff2) do
  1051.                   begin
  1052.                        if (buff2[i] = ':') then
  1053.                           if (buff2[i+1] <> '\') then
  1054.                           begin
  1055.                               buff3 := Copy(buff, 1, 3 + i);
  1056.                               dpos := i;
  1057.                               break;
  1058.                           end;
  1059.                   end;
  1060.              end;
  1061.              { Read Command }
  1062.              for i:=dpos to Length(buff2) do
  1063.              begin
  1064.                   if (buff2[i] = ':') then
  1065.                      if (isKigou(buff2[i+1]) = 0) then
  1066.                      begin
  1067.                           dpos := i + 1;
  1068.                           break
  1069.                      end;
  1070.              end;
  1071.              for i:=dpos to Length(buff2) do
  1072.                  begin
  1073.                  if (buff2[i] = ';') then
  1074.                  begin
  1075.                       epos := i - 1;
  1076.                       break;
  1077.                  end;
  1078.              end;
  1079.              exeName := Copy(buff2, dpos, epos - dpos + 1);
  1080.              pathName := buff3;
  1081.              docName := Copy(buff2, epos + 2, Length(buff2) - epos - 2 + 1);
  1082.  
  1083.              { Open Picture }
  1084.              buff := exeName;
  1085.              buff2 := buff;
  1086.              if (POS(' 1 JPEGED', buff) > 0) then
  1087.              begin
  1088.                   buff  := Copy(buff, POS(' 1 ', buff) + 8, Length(buff) - POS(' 1 ', buff) - 8 + 1);
  1089.              end;
  1090.              if (POS(' P ', buff) > 0) then
  1091.              begin
  1092.                   buff  := Copy(buff, POS(' P ', buff) + 2, Length(buff) - POS(' P ', buff) - 2 + 1);
  1093.              end;
  1094.              for i:=1 to Length(buff) do
  1095.              begin
  1096.                   if (buff[i] = ' ') And (buff[i+1] <> '/') And (buff[i+1] <> '-') then
  1097.                   begin
  1098.                        exeName  := Copy(buff, i + 1, Length(buff) - i + 1 + 1);
  1099.                        break;
  1100.                   end;
  1101.              end;
  1102.              if (Pos(':\', exeName) = 0) then
  1103.                 exeName := structName(buff3 + exeName)
  1104.              else
  1105.                 exeName := structName(exeName);
  1106.              if (ExtractFileExt(exeName) = '') then
  1107.              begin
  1108.                   if (compareText(Copy(buff2, 1, 3),'PIC') = 0) then
  1109.                      exeName := exeName + '.PIC';
  1110.                   if (compareText(Copy(buff2, 1, 2),'KT') = 0) then
  1111.                      exeName := exeName + '.PIC';
  1112.                   if (compareText(Copy(buff2, 1, 3),'JPE') = 0) then
  1113.                      exeName := exeName + '.JPG';
  1114.              end;
  1115.              if (picFlag = 1) then
  1116.                 fock(picProg, exeName, picParam);
  1117.              { Open NextFile }
  1118.              if (pathName <> '') then
  1119.              begin
  1120.                 buff := structName(pathName + 'a.b');
  1121.                 buffPath := ExtractFilePath(buff);
  1122.                 currentPath := buffPath;
  1123.              end;
  1124.              { StructNewFileName }
  1125.              currentFileName := structName(docName);
  1126.              if (Pos(';', currentFileName)>0) then
  1127.                 currentFileName := Copy(currentFileName, 1, length(currentFileName)+Pos(';', currentFileName)-2);
  1128.              loadText(currentFileName);
  1129.              if (dcvError>0) then
  1130.              begin
  1131.                   dcvError := 0;
  1132.                   returnDoc(0);
  1133.                   exit;
  1134.              end;
  1135.              if (currentPath <> buffPath) And (pathName <> '') then
  1136.                 currentPath := buffPath;
  1137.              drawText(displine, 0);
  1138.              exit;
  1139.         end;
  1140.  
  1141.         if (CompareText(buff3, 'EXE') = 0) Or (CompareText(buff3, 'CLI') = 0) then
  1142.         { Execute PictureLoad }
  1143.         begin
  1144.              buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
  1145.              { Open Picture }
  1146.              if (POS(' 1 JPEGED', buff) > 0) then
  1147.              begin
  1148.                   buff  := Copy(buff, POS(' 1 ', buff) + 8, Length(buff) - POS(' 1 ', buff) - 8 + 1);
  1149.              end;
  1150.              if (POS(' P ', buff) > 0) then
  1151.              begin
  1152.                   buff  := Copy(buff, POS(' P ', buff) + 2, Length(buff) - POS(' P ', buff) - 2 + 1);
  1153.              end;
  1154.              exeName := '';
  1155.              for i:=1 to Length(buff) do
  1156.              begin
  1157.                   if (buff[i] = ' ') And (buff[i+1] <> '/') And (buff[i+1] <> '-') then
  1158.                   begin
  1159.                        exeName  := Copy(buff, i + 1, Length(buff) - i - 1 + 1);
  1160.                        break;
  1161.                   end;
  1162.              end;
  1163.              if (Length(exeName) < 1) then
  1164.              begin
  1165.                   MessageDlg('このファイルは実行できません!', mtError, [mbOK], 0);
  1166.                   dcvError := 1;
  1167.                   exit;
  1168.              end;
  1169.              exeName := structName(exeName);
  1170.              execFlag := 0;
  1171.              if (Pos('KT ', buff2) > 0) Or (Pos('PIC ', buff2) > 0) Or (Pos('GP11 ', buff2) > 0) then
  1172.              begin
  1173.                   if (ExtractFileExt(exeName) = '') then
  1174.                      exeName := exeName + '.PIC';
  1175.                   execFlag := 1;
  1176.              end;
  1177.              if (Pos('JPEGED ', buff2) > 0) Or (Pos('DJ ', buff2) > 0) then
  1178.              begin
  1179.                   if (ExtractFileExt(exeName) = '') then
  1180.                      exeName := exeName + '.JPG';
  1181.                   execFlag := 1;
  1182.              end;
  1183.              if (execFlag = 1) And (picFlag = 1) then
  1184.                 fock(picProg, exeName, picParam);
  1185.              exit;
  1186.         end;
  1187.         { Now Abundon Process }
  1188.         exit;
  1189.    end;
  1190. end;
  1191.  
  1192. function changePath(name: String): String;
  1193. var
  1194.    buff: String;
  1195.    nbuff: Array [0..255] of Char;
  1196.    mpos: Integer;
  1197. begin
  1198.    { CangeDirectory }
  1199.    StrPCopy(nbuff, name);
  1200.    if (StrRScan(nbuff, ':') <> nil) then
  1201.       StrRScan(nbuff, ':')^ := '\';
  1202.    name := StrPas(nbuff);
  1203.    if (POS(':+', name) > 0)then
  1204.    begin
  1205.         mpos := POS(':+', name);
  1206.         name[mpos] := '#';
  1207.         name[mpos + 1] := '#';
  1208.    end;
  1209.    if (POS(':*', name) > 0)then
  1210.    begin
  1211.         mpos := POS(':*', name);
  1212.         name[mpos] := '#';
  1213.         name[mpos + 1] := '#';
  1214.    end;
  1215.    While POS('#', name) > 0 do
  1216.    begin
  1217.          mpos := POS('#', name);
  1218.          name := Copy(name, 1, mpos - 1) + Copy(name, mpos + 1, Length(name));
  1219.    end;
  1220.    buff := Copy(name, 4, Length(name) - 3 + 1);
  1221.    changePath := buff;
  1222. end;
  1223.  
  1224. function structName(name: String): String;
  1225. begin
  1226.    { 'CD' Exist? }
  1227.    if (compareText('CD=', Copy(name, 1, 3)) = 0)
  1228.    Or (compareText('CD ', Copy(name, 1, 3)) = 0) then
  1229.       name := changePath(name);
  1230.    if (compareText('CK=', Copy(name, 1, 3)) = 0) then
  1231.         name := Copy(name, 6, Length(name) - 6 + 1);
  1232.    { Normal Pattern }
  1233.    if (compareText('A:\', Copy(name, 1, 3)) = 0) then
  1234.       structName := a_Path + Copy(name, 3, Length(name) - 3 + 1)
  1235.    else if (compareText('B:\', Copy(name, 1, 3)) = 0) then
  1236.       structName := b_Path + Copy(name, 3, Length(name) - 3 + 1)
  1237.    else if (compareText('B:', Copy(name, 1, 2)) = 0) then
  1238.       structName := b_Path + '\' + Copy(name, 3, Length(name) - 3 + 1)
  1239.    else if (compareText('C:\', Copy(name, 1, 3)) = 0) then
  1240.       structName := c_Path + Copy(name, 3, Length(name) - 3 + 1)
  1241.    else if (name[1] = '\') then
  1242.       structName := a_path + name
  1243.    else
  1244.       structName := currentPath + name;
  1245.    name := name;
  1246. end;
  1247.  
  1248. function returnDoc(dispmode: Integer): Boolean;
  1249. begin
  1250.      scroll := 0;
  1251.      if (depth > 0) then
  1252.      { Pop FileName }
  1253.      begin
  1254.           currentFileName := recordFileName[depth-1];
  1255.           loadText(currentFileName);
  1256.           if (dcvError>0) then
  1257.           begin
  1258.              dcvError := 0;
  1259.              exit;
  1260.           end;
  1261.           depth := depth - 1;
  1262.           currentPath := recordPath[depth];
  1263.           displine := recorddispline[depth];
  1264.           form1.scrollbar1.position := displine;
  1265.           drawText(displine, dispmode);
  1266.           if (depth < 1) then
  1267.              form1.button7.enabled := False;
  1268.      end;
  1269. end;
  1270.  
  1271. procedure TForm1.FormCreate(Sender: TObject);
  1272. var
  1273.    i: Integer;
  1274.    ff: Integer;
  1275. begin
  1276.      BorderIcons := BorderIcons - [biMaximize];
  1277.      { Set WindowTitle }
  1278.      form1.Caption :='DC_VIEW';
  1279.      { Initialize Value }
  1280.      isLoad := 0;
  1281.      depth := 0;
  1282.      sFontSize := 9;
  1283.      lFontSize := 12;
  1284.      sFontHight := 12;
  1285.      sFontWidth := 6;
  1286.      lFontHight := 16;
  1287.      lFontWidth := 8;
  1288.      dcvError := 0;
  1289.      pastline := 0;
  1290.      for i:=0 to 40 do
  1291.          cutExe[i] := 0;
  1292.      dcBmpOk := 0;
  1293.      { Read .INI File }
  1294.      if (FileExists('DC_VIEW.INI') = True) then
  1295.      begin
  1296.         ownPath := ExtractFilePath(ExpandFileName('DC_VIEW.INI'));
  1297.         SetIni(ExpandFileName('DC_VIEW.INI'))
  1298.      end
  1299.      else
  1300.      begin
  1301.           MessageDlg('DC_VIEW.INIがありません。新しく作成します。',mtError, [mbOK], 0);
  1302.           ownPath := ExtractFilePath(ExpandFileName('DC_VIEW.EXE'));
  1303.           ff := FileCreate(ownPath + 'DC_VIEW.INI');
  1304.           FileClose(ff);
  1305.           SetIni(ExpandFileName('DC_VIEW.INI'))
  1306.      end;
  1307.      { Setup FontSize }
  1308.      case FontSize of
  1309.      0:SetSmallFont(0);
  1310.      1:SetLargeFont(0);
  1311.      end;
  1312.      { SetUp ImageScreen }
  1313.      form1.image1.canvas.font.Name := 'MS ゴシック';
  1314.      slFontType := 'MS ゴシック';
  1315.      form1.image1.canvas.font.pitch := fpFixed;
  1316.      isBmpCreate := 1;
  1317.      form1.image1.top := 0;
  1318.      form1.image1.left := 0;
  1319.      { SetUp Window Condition }
  1320.      winRc := Rect(0,0,form1.image1.width,form1.image1.height);
  1321.      setConditions(0);
  1322.      setCondition2(0);
  1323.      form1.image1.canvas.FillRect(winRc);
  1324.      { Disable Control }
  1325.      form1.button1.enabled := False;
  1326.      form1.button2.enabled := False;
  1327.      form1.button3.enabled := False;
  1328.      form1.button4.enabled := False;
  1329.      form1.button5.enabled := False;
  1330.      form1.button6.enabled := False;
  1331.      form1.button7.enabled := False;
  1332.      form1.button8.enabled := False;
  1333.      form1.button9.enabled := False;
  1334.      form1.scrollbar1.enabled := False;
  1335.      form1.print1.enabled := False;
  1336.      form1.printsetup1.enabled := False;
  1337.      form1.KE1.enabled := False;
  1338.      form1.KEditer1.enabled := False;
  1339.      { Run With Parameters? }
  1340.      if (Paramcount > 0) then
  1341.      begin
  1342.           currentFileName := ParamStr(1);
  1343.           loadText(currentFileName);
  1344.           if (dcvError>0) then
  1345.           begin
  1346.                dcvError := 0;
  1347.                exit;
  1348.           end;
  1349.           drawText(displine, 0);
  1350.      end;
  1351.      Form1.Visible := True;
  1352.      { Enable Get DropFileName }
  1353. end;
  1354.  
  1355. procedure TForm1.Timer1Timer(Sender: TObject);
  1356. var
  1357.    temp: Integer;
  1358. begin
  1359.      Timer1.Interval := 10;
  1360.      { Scroll? }
  1361.      if (scroll =  0) then exit;
  1362.      if (scroll = -1) And (displine = 0) then exit;
  1363.      if (scroll =  1) And (displine = currentFileLine - 30) then exit;
  1364.      { Dshell Scroll }
  1365.      if ((displine + scroll * step) < 0) then
  1366.      begin
  1367.           temp := step;
  1368.           step := displine;
  1369.           setCondition2(0);
  1370.           displine := 0;
  1371.           drawText(displine, 1);
  1372.           step := temp;
  1373.           setCondition2(0);
  1374.           exit;
  1375.      end;
  1376.      if ((displine + scroll * step) > (currentFileLine - 30)) then
  1377.      begin
  1378.           temp := step;
  1379.           step := (currentFileLine - 30) - displine;
  1380.           setCondition2(0);
  1381.           displine := currentFileLine - 30;
  1382.           drawText(displine, 1);
  1383.           step := temp;
  1384.           setCondition2(0);
  1385.           exit;
  1386.      end;
  1387.      displine := displine + scroll * step;
  1388.      drawText(displine, 1);
  1389. end;
  1390.  
  1391. procedure TForm1.Button1Click(Sender: TObject);
  1392. begin
  1393.      displine := 0;
  1394.      drawText(displine, 0);
  1395.      { Stop SCroll }
  1396.      scroll := 0;
  1397.      mbtn := 0;
  1398. end;
  1399.  
  1400. procedure TForm1.Button2Click(Sender: TObject);
  1401. begin
  1402.      displine := currentFileLine - 30;
  1403.      if (displine < 0) then
  1404.           displine := 0;
  1405.      drawText(displine, 0);
  1406.      { Stop SCroll }
  1407.      scroll := 0;
  1408.      mbtn := 0;
  1409. end;
  1410.  
  1411. procedure TForm1.Button3Click(Sender: TObject);
  1412. begin
  1413.      displine := displine - 1;
  1414.      if (displine < 0) then
  1415.         displine := 0;
  1416.      drawText(displine, 0);
  1417.      { Stop SCroll }
  1418.      scroll := 0;
  1419.      mbtn := 0;
  1420. end;
  1421.  
  1422. procedure TForm1.Button4Click(Sender: TObject);
  1423. begin
  1424.      displine := displine + 1;
  1425.      if (displine > currentFileLine - 30) then
  1426.         displine := currentFileLine - 30;
  1427.      drawText(displine, 0);
  1428.      { Stop SCroll }
  1429.      scroll := 0;
  1430.      mbtn := 0;
  1431. end;
  1432.  
  1433. procedure TForm1.Button8Click(Sender: TObject);
  1434. begin
  1435.      displine := displine - 29;
  1436.      if (displine < 30) then
  1437.         displine := 0;
  1438.      drawText(displine, 0);
  1439.      { Stop SCroll }
  1440.      scroll := 0;
  1441.      mbtn := 0;
  1442. end;
  1443.  
  1444. procedure TForm1.Button9Click(Sender: TObject);
  1445. begin
  1446.      displine := displine + 29;
  1447.      if (displine > currentFileLine - 30) then
  1448.         displine := currentFileLine - 30;
  1449.      drawText(displine, 0);
  1450.      { Stop SCroll }
  1451.      scroll := 0;
  1452.      mbtn := 0;
  1453. end;
  1454.  
  1455. procedure TForm1.Button7Click(Sender: TObject);
  1456. begin
  1457.      returnDoc(0);
  1458.      { Stop SCroll }
  1459.      scroll := 0;
  1460.      mbtn := 0;
  1461. end;
  1462.  
  1463. procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
  1464.   var ScrollPos: Integer);
  1465. begin
  1466.      if (scroll <> 0) then exit;
  1467.      displine := scrollbar1.position;
  1468.      drawText(displine, 0);
  1469. end;
  1470.  
  1471. procedure TForm1.K2Click(Sender: TObject);
  1472. begin
  1473.      AboutBox.ShowModal;
  1474. end;
  1475.  
  1476. procedure TForm1.N11Click(Sender: TObject);
  1477. begin
  1478.      CheckScroll(step);
  1479.      step := 1;
  1480.      N11.Checked := True;
  1481.      setCondition2(0);
  1482. end;
  1483.  
  1484. procedure TForm1.N21Click(Sender: TObject);
  1485. begin
  1486.      CheckScroll(step);
  1487.      step := 2;
  1488.      N21.Checked := True;
  1489.      setCondition2(0);
  1490. end;
  1491.  
  1492. procedure TForm1.N31Click(Sender: TObject);
  1493. begin
  1494.      CheckScroll(step);
  1495.      step := 3;
  1496.      N31.Checked := True;
  1497.      setCondition2(0);
  1498. end;
  1499.  
  1500. procedure TForm1.N41Click(Sender: TObject);
  1501. begin
  1502.      CheckScroll(step);
  1503.      step := 4;
  1504.      N41.Checked := True;
  1505.      setCondition2(0);
  1506. end;
  1507.  
  1508. procedure TForm1.N51Click(Sender: TObject);
  1509. begin
  1510.      CheckScroll(step);
  1511.      step := 5;
  1512.      N51.Checked := True;
  1513.      setCondition2(0);
  1514. end;
  1515.  
  1516. procedure TForm1.N61Click(Sender: TObject);
  1517. begin
  1518.      CheckScroll(step);
  1519.      step := 6;
  1520.      N61.Checked := True;
  1521.      setCondition2(0);
  1522. end;
  1523.  
  1524. function CheckScroll(qc:Integer): Boolean;
  1525. begin
  1526.      case qc of
  1527.      1:Form1.N11.Checked := False;
  1528.      2:Form1.N21.Checked := False;
  1529.      3:Form1.N31.Checked := False;
  1530.      4:Form1.N41.Checked := False;
  1531.      5:Form1.N51.Checked := False;
  1532.      6:Form1.N61.Checked := False;
  1533.      end;
  1534. end;
  1535.  
  1536. function fock(fockFileName, Params, DefaultDir: String): Integer;
  1537. var
  1538.   zFileName, zParams, zDir: array[0..79] of Char;
  1539. begin
  1540.      fock := ShellExecute(Form1.Handle, nil,
  1541.         StrPCopy(zFileName, fockFileName), StrPCopy(zParams, Params),
  1542.         StrPCopy(zDir, DefaultDir), SW_SHOW);
  1543. end;
  1544.  
  1545. procedure TForm1.KEditer1Click(Sender: TObject);
  1546. begin
  1547.      if (edtFlag = 1) And (isLoad = 1) then
  1548.         fock(edtProg, currentFileName, edtParam);
  1549. end;
  1550.  
  1551. function isKanji(ck: Char): Integer;
  1552. begin
  1553.      if ((ck >= Chr(129)) And (ck <= Chr(159))) Or ((ck >= Chr(224)) And ( ck<= Chr(239))) then
  1554.         isKanji := 1
  1555.      else
  1556.         isKanji := 0;
  1557. end;
  1558.  
  1559. function isKigou(cc: Char): Integer;
  1560. begin
  1561.      if (Pos(cc, '-+*') > 0) then
  1562.         isKigou := 1
  1563.      else
  1564.         isKigou := 0;
  1565. end;
  1566.  
  1567. function isExcept(ce: String): Integer;
  1568. begin
  1569.      if (Pos(ce, 'ぁぃぅぇぉゃゅょっゎァィゥェォャュョッヮ'
  1570.        +'、。,.?!゛´`‘“)〕]}〉》」』】>') > 0) then
  1571.         isExcept := 1
  1572.      else
  1573.         isExcept := 0;
  1574. end;
  1575.  
  1576. procedure TForm1.K3Click(Sender: TObject);
  1577. var
  1578.    done: Integer;
  1579. begin
  1580.      { Set 起動表示 Window }
  1581.      BtnRightDlg.edit1.text := picProg;
  1582.      BtnRightDlg.edit2.text := picParam;
  1583.      if (picFlag = 0) then
  1584.         BtnRightDlg.checkbox1.state := cbUnchecked
  1585.      else
  1586.         BtnRightDlg.checkbox1.state := cbChecked;
  1587.      BtnRightDlg.caption := '画像表示プログラム選択';
  1588.      BtnRightDlg.ShowModal;
  1589.      if (dc_dlog.can(done) = 1) then exit;
  1590.      { SetUp Condition }
  1591.      picProg := dc_dlog.retCom(picProg);
  1592.      picParam := dc_dlog.retParam(PicParam);
  1593.      picFlag := dc_dlog.retpic(picFlag);
  1594. end;
  1595.  
  1596. procedure TForm1.K4Click(Sender: TObject);
  1597. var
  1598.    done: Integer;
  1599. begin
  1600.      { Set 起動表示 Window }
  1601.      BtnRightDlg.edit1.text := edtProg;
  1602.      BtnRightDlg.edit2.text := edtParam;
  1603.      if (edtFlag = 0) then
  1604.         BtnRightDlg.checkbox1.state := cbUnchecked
  1605.      else
  1606.         BtnRightDlg.checkbox1.state := cbChecked;
  1607.      BtnRightDlg.caption := 'エディタプログラム選択';
  1608.      BtnRightDlg.ShowModal;
  1609.      if (dc_dlog.can(done) = 1) then exit;
  1610.      { SetUp Condition }
  1611.      edtProg := dc_dlog.retCom(edtProg);
  1612.      edtParam := dc_dlog.retParam(edtParam);
  1613.      edtFlag := dc_dlog.retpic(edtFlag);
  1614.      if (edtFlag = 0) then
  1615.         form1.KEditer1.enabled := False
  1616.      else
  1617.         form1.KEditer1.enabled := True;
  1618. end;
  1619.  
  1620. procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  1621.   Shift: TShiftState; X, Y: Integer);
  1622. var
  1623.    buff, buff2: String;
  1624.    line, pick: PChar;
  1625.    nowPtr, nextPtr, linesize: Longint;
  1626. begin
  1627.     { Already Loaded? }
  1628.     if isLoad = 0 then exit;
  1629.     { ReturnTo PastFile }
  1630.     if ((mbtn = 1) And (Button = mbRight))
  1631.        or ((mbtn = -1) And (Button = mbLeft)) then
  1632.        begin
  1633.             returnDoc(0);
  1634.             exit;
  1635.        end;
  1636.    { Command Area? }
  1637.     if (Button = mbLeft) And (X < sFontHight) then
  1638.         begin
  1639.              GetMem(line, 256);
  1640.              pick := GlobalLock(txtHdl);
  1641.              nowPtr := Longint(dcLine[displine + (y div sFontHight) + 1]);
  1642.              nextPtr := Longint(dcLine[displine + (y div sFontHight) + 2]);
  1643.              Inc(pick, nowPtr);
  1644.              linesize := nextPtr - nowPtr + 1;
  1645.              StrMove(line, pick, linesize);
  1646.              buff2 := StrPas(line);
  1647.              buff2 := Copy(buff2, 1, Pos(Chr(13), buff2) - 1);
  1648.              nextFile(buff2, buff);
  1649.              GlobalUnlock(txtHdl);
  1650.              FreeMem(line, 256);
  1651.              exit;
  1652.         end;
  1653.     { DShell Scroll Start}
  1654.     if (Button = mbLeft) then
  1655.         if (displine + step > currentFileLine - 30) then
  1656.            scroll :=  0
  1657.         else
  1658.            scroll :=  1
  1659.     else
  1660.         if (displine - step < 0) then
  1661.            scroll :=  0
  1662.         else
  1663.            scroll := -1;
  1664.     { Set ButtonStatus }
  1665.     if (Button = mbLeft) then
  1666.         mbtn := 1
  1667.     else
  1668.         mbtn := -1;
  1669.  
  1670. end;
  1671.  
  1672. procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  1673.   Shift: TShiftState; X, Y: Integer);
  1674. begin
  1675.      { Stop SCroll }
  1676.      scroll := 0;
  1677.      mbtn := 0;
  1678. end;
  1679.  
  1680. procedure TForm1.K5Click(Sender: TObject);
  1681. begin
  1682.      if (dispCut = 0) then
  1683.      begin
  1684.           K5.Checked := True;
  1685.           dispCut := 1;
  1686.           exit;
  1687.      end;
  1688.      K5.Checked := False;
  1689.      dispCut := 0;
  1690. end;
  1691.  
  1692. procedure TForm1.Button5Click(Sender: TObject);
  1693. var
  1694.    sPtr: PChar;
  1695.    i: Integer;
  1696.    dep: String;
  1697. begin
  1698.      if (isLoad = 0) then exit;
  1699.      if (displine <= 1) then exit;
  1700.      sPtr := GlobalLock(txtHdl);
  1701.      for i:= (displine - 1) downto 1 do
  1702.      begin
  1703.           dep := '';
  1704.           dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]))^;
  1705.           dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]) + 1)^;
  1706.           if (dep = '━') then
  1707.           begin
  1708.                displine := i - 1;
  1709.                drawText(displine, 0);
  1710.                break;
  1711.           end;
  1712.      end;
  1713.      GlobalUnlock(txtHdl);
  1714.      { Stop SCroll }
  1715.      scroll := 0;
  1716.      mbtn := 0;
  1717. end;
  1718.  
  1719. procedure TForm1.Button6Click(Sender: TObject);
  1720. var
  1721.    sPtr: PChar;
  1722.    i: Integer;
  1723.    dep: String;
  1724. begin
  1725.      if (isLoad = 0) then exit;
  1726.      if (displine >= currentFileLine - 30) then exit;
  1727.      sPtr := GlobalLock(txtHdl);
  1728.      for i:= (displine + 2) to currentFileLine do
  1729.      begin
  1730.           dep := '';
  1731.           dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]))^;
  1732.           dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]) + 1)^;
  1733.           if (dep = '━') then
  1734.           begin
  1735.                displine := i - 1;
  1736.                if (displine > currentFileLine - 30) then
  1737.                   displine := currentFileLine - 30;
  1738.                drawText(displine, 0);
  1739.                break;
  1740.           end;
  1741.      end;
  1742.      GlobalUnlock(txtHdl);
  1743.      { Stop SCroll }
  1744.      scroll := 0;
  1745.      mbtn := 0;
  1746. end;
  1747.  
  1748. procedure TForm1.KS1Click(Sender: TObject);
  1749. begin
  1750.      pastline := 0;
  1751.      if (isLoad = 0) then exit;
  1752.      FindDialog1.Execute;
  1753. end;
  1754.  
  1755. function findTextDown(sTxt: String): Boolean;
  1756. var
  1757.    sPtr, sLine: PChar;
  1758.    i, s1, s2: Longint;
  1759.    dep: String;
  1760. begin
  1761.      if (isLoad = 0) then exit;
  1762.      GetMem(sLine, 256);
  1763.      sPtr := GlobalLock(txtHdl);
  1764.      for i:= pastline + 1 to currentFileLine-3 do
  1765.      begin
  1766.           s1 := Longint(sPtr) + Longint(dcLine[i+1]);
  1767.           s2 := Longint(dcLine[i+2]) - Longint(dcLine[i+1]) + 1;
  1768.           StrMove(sLine, PChar(s1), s2);
  1769.           sLine[s2+1] := Chr(0);
  1770.           dep := StrPas(sLine);
  1771.           if ((form1.FindDialog1.Options*[frMatchCase])<>[frMatchCase]) then
  1772.           begin
  1773.                sTxt := AnsiUpperCase(sTxt);
  1774.                dep := AnsiUpperCase(dep);
  1775.           end;
  1776.           if (Pos(sTxt, dep) > 0) then
  1777.           begin
  1778.                displine := i - 15;
  1779.                if (displine > currentFileLine - 30) then
  1780.                   displine := currentFileLine - 30;
  1781.                if (displine < 0) then
  1782.                   displine := 0;
  1783.                drawText(displine, 0);
  1784.                drawSLine(i);
  1785.                pastline := i;
  1786.                FreeMem(sLine, 256);
  1787.                GlobalUnlock(txtHdl);
  1788.                exit;
  1789.           end;
  1790.      end;
  1791.      drawText(displine, 0);
  1792.      FreeMem(sLine, 256);
  1793.      GlobalUnlock(txtHdl);
  1794. end;
  1795.  
  1796. function findTextUp(sTxt: String): Boolean;
  1797. var
  1798.    sPtr, sLine: PChar;
  1799.    i, s1, s2: Longint;
  1800.    dep: String;
  1801. begin
  1802.      if (isLoad = 0) then exit;
  1803.      GetMem(sLine, 256);
  1804.      sPtr := GlobalLock(txtHdl);
  1805.      for i:= pastline - 1 downto 0 do
  1806.      begin
  1807.           s1 := Longint(sPtr) + Longint(dcLine[i+1]);
  1808.           s2 := Longint(dcLine[i+2]) - Longint(dcLine[i+1]) + 1;
  1809.           StrMove(sLine, PChar(s1), s2);
  1810.           sLine[s2+1] := Chr(0);
  1811.           dep := StrPas(sLine);
  1812.           if ((form1.FindDialog1.Options*[frMatchCase])<>[frMatchCase]) then
  1813.           begin
  1814.                sTxt := AnsiUpperCase(sTxt);
  1815.                dep := AnsiUpperCase(dep);
  1816.           end;
  1817.           if (Pos(sTxt, dep) > 0) then
  1818.           begin
  1819.                displine := i - 15;
  1820.                if (displine > currentFileLine - 30) then
  1821.                   displine := currentFileLine - 30;
  1822.                if (displine < 0) then
  1823.                   displine := 0;
  1824.                drawText(displine, 0);
  1825.                drawSLine(i);
  1826.                pastline := i;
  1827.                FreeMem(sLine, 256);
  1828.                GlobalUnlock(txtHdl);
  1829.                exit;
  1830.           end;
  1831.      end;
  1832.      drawText(displine, 0);
  1833.      FreeMem(sLine, 256);
  1834.      GlobalUnlock(txtHdl);
  1835. end;
  1836.  
  1837. function drawSLine(ll: Longint): Boolean;
  1838. var
  1839.    ldone, lll: Integer;
  1840. begin
  1841.      ldone := 0;
  1842.      lll := ll + 1;
  1843.      form1.image1.canvas.pen.color := clRed;
  1844.      if (ll < 15) then
  1845.      begin
  1846.           form1.image1.canvas.MoveTo(0, lll * sFontHight);
  1847.           form1.image1.canvas.LineTo(form1.clientWidth, lll * sFontHight);
  1848.           ldone := 1;
  1849.      end;
  1850.      if (ll > currentFileLine - 15) then
  1851.      begin
  1852.           form1.image1.canvas.MoveTo(0, (lll - displine) * sFontHight);
  1853.           form1.image1.canvas.LineTo(form1.clientWidth, (lll - displine) * sFontHight);
  1854.           ldone := 1;
  1855.      end;
  1856.      if (ldone = 0) then
  1857.      begin
  1858.           form1.image1.canvas.MoveTo(0, 16 * sFontHight);
  1859.           form1.image1.canvas.LineTo(form1.clientWidth, 16 * sFontHight);
  1860.      end;
  1861.      form1.image1.canvas.pen.color := clWhite;
  1862. end;
  1863.  
  1864. procedure TForm1.KG1Click(Sender: TObject);
  1865. begin
  1866.      findTextDown(FindDialog1.FindText);
  1867. end;
  1868.  
  1869. procedure TForm1.K1Click(Sender: TObject);
  1870. begin
  1871.      findTextUp(FindDialog1.FindText);
  1872. end;
  1873.  
  1874. procedure TForm1.FindDialog1Find(Sender: TObject);
  1875. begin
  1876.      if ((FindDialog1.Options*[frDown])=[frDown]) then
  1877.         findTextDown(FindDialog1.FindText)
  1878.      else
  1879.         findTextUp(FindDialog1.FindText);
  1880. end;
  1881.  
  1882. procedure TForm1.KS2Click(Sender: TObject);
  1883. begin
  1884.   FontDialog1.Font := form1.image1.canvas.Font;
  1885.   FontDialog1.Font.color := clBlack;
  1886.   if FontDialog1.Execute then
  1887.      form1.image1.canvas.Font := FontDialog1.Font;
  1888.      slFontType := FontDialog1.Font.Name;
  1889.   form1.image1.canvas.font.size := sFontSize;
  1890.   form1.image1.canvas.font.style := [];
  1891.   form1.image1.canvas.font.color := clWhite;
  1892.   drawText(displine, 0);
  1893. end;
  1894.  
  1895. procedure TForm1.N1624DotPare1Click(Sender: TObject);
  1896. begin
  1897.      { Set LargeCharacter }
  1898.      SetLargeFont(FontSize);
  1899.      FontSize := 1;
  1900.      Form1.N1216DotPare1.Checked := False;
  1901.      Form1.N1624DotPare1.Checked := True;
  1902. end;
  1903.  
  1904. function SetLargeFont(FS1:Integer):Boolean;
  1905. begin
  1906.      sFontSize := 12;
  1907.      lFontSize := 16;
  1908.      sFontHight := 16;
  1909.      sFontWidth := 8;
  1910.      lFontHight := 24;
  1911.      lFontWidth := 12;
  1912.      { Set WindowSize }
  1913.      if (dcBmpOk = 1) then dcBmp.Free;
  1914.      dcBmp := TBitmap.create;
  1915.      dcBmpOk := 1;
  1916.      dcBmp.height := 480+18;
  1917.      dcBmp.width := 768;
  1918.      Form1.clientheight := 480+18;
  1919.      Form1.clientwidth := 768;
  1920.      Form1.Image1.Picture.Graphic := dcBmp;
  1921.      form1.image1.canvas.font.size := 12;
  1922.      form1.image1.canvas.font.Name := slFontType;
  1923.      form1.image1.canvas.font.pitch := fpFixed;
  1924.      SetConditions(0);
  1925.      SetCondition2(0);
  1926.      winRc := Rect(0,0,form1.image1.width,form1.image1.height);
  1927.      form1.image1.canvas.FillRect(winRc);
  1928.  
  1929.      Form1.Button1.Top := 480;
  1930.      Form1.Button2.Top := 480;
  1931.      Form1.Button3.Top := 480;
  1932.      Form1.Button4.Top := 480;
  1933.      Form1.Button5.Top := 480;
  1934.      Form1.Button6.Top := 480;
  1935.      Form1.Button7.Top := 480;
  1936.      Form1.Button7.Left := 530+192;
  1937.      Form1.Button8.Top := 480;
  1938.      Form1.Button9.Top := 480;
  1939.      Form1.Panel1.Top := 480;
  1940.      Form1.Panel1.Left := 480+192;
  1941.      Form1.ScrollBar1.Top := 480;
  1942.      Form1.ScrollBar1.Width := 160+192;
  1943.      drawText(displine, 0);
  1944. end;
  1945.  
  1946. procedure TForm1.N1216DotPare1Click(Sender: TObject);
  1947. begin
  1948.      { Set LargeCharacter }
  1949.      SetSmallFont(FontSize);
  1950.      FontSize := 0;
  1951.      Form1.N1216DotPare1.Checked := True;
  1952.      Form1.N1624DotPare1.Checked := False;
  1953. end;
  1954.  
  1955. function SetSmallFont(FS2:Integer):Boolean;
  1956. begin
  1957.      sFontSize := 9;
  1958.      lFontSize := 12;
  1959.      sFontHight := 12;
  1960.      sFontWidth := 6;
  1961.      lFontHight := 16;
  1962.      lFontWidth := 8;
  1963.      { Set WindowSize }
  1964.      if (dcBmpOk = 1) then dcBmp.Free;
  1965.      dcBmp := TBitmap.create;
  1966.      dcBmpOk := 1;
  1967.      dcBmp.height := 360+18;
  1968.      dcBmp.width := 576;
  1969.      Form1.clientheight := 360+18;
  1970.      Form1.clientwidth := 576;
  1971.      Form1.Image1.Picture.Graphic := dcBmp;
  1972.      form1.image1.canvas.font.size := 9;
  1973.      form1.image1.canvas.font.Name := slFontType;
  1974.      form1.image1.canvas.font.pitch := fpFixed;
  1975.      setConditions(0);
  1976.      setCondition2(0);
  1977.      winRc := Rect(0,0,form1.image1.width,form1.image1.height);
  1978.      form1.image1.canvas.FillRect(winRc);
  1979.  
  1980.      Form1.Button1.Top := 360;
  1981.      Form1.Button2.Top := 360;
  1982.      Form1.Button3.Top := 360;
  1983.      Form1.Button4.Top := 360;
  1984.      Form1.Button5.Top := 360;
  1985.      Form1.Button6.Top := 360;
  1986.      Form1.Button7.Top := 360;
  1987.      Form1.Button7.Left := 530;
  1988.      Form1.Button8.Top := 360;
  1989.      Form1.Button9.Top := 360;
  1990.      Form1.Panel1.Top := 360;
  1991.      Form1.Panel1.Left := 480;
  1992.      Form1.ScrollBar1.Top := 360;
  1993.      Form1.ScrollBar1.Width := 160;
  1994.      drawText(displine, 0);
  1995. end;
  1996.  
  1997. procedure TForm1.KM1Click(Sender: TObject);
  1998. begin
  1999.   Application.HelpFile := 'DC_VIEW.HLP';
  2000.   Application.HelpCommand(HELP_CONTENTS, 0);
  2001. end;
  2002.  
  2003. procedure TForm1.KK1Click(Sender: TObject);
  2004. begin
  2005.   Application.HelpFile := 'DC_VIEW.HLP';
  2006.   Application.HelpCommand(HELP_PARTIALKEY, 0);
  2007. end;
  2008.  
  2009. procedure TForm1.KH1Click(Sender: TObject);
  2010. begin
  2011.   Application.HelpFile := 'WINHELP.HLP';
  2012.   Application.HelpCommand(HELP_CONTENTS, 0);
  2013. end;
  2014.  
  2015. function SetIni(ini: String): Boolean;
  2016. var
  2017.   IniFile: TIniFile;
  2018.   param: Integer;
  2019. begin
  2020.      IniFile := TIniFile.Create(ini);
  2021.      With IniFile do
  2022.      begin
  2023.           { FontSize }
  2024.           if ReadString('Font', 'FontSize', 'Small') = 'Small' then
  2025.              FontSize := 0
  2026.           else
  2027.              FontSize := 1;
  2028.           case FontSize of
  2029.           0:Form1.N1216DotPare1.Checked := True;
  2030.           1:Form1.N1624DotPare1.Checked := True;
  2031.           end;
  2032.           { CutFile Disp? }
  2033.           if ReadString('Cut', 'Visible', 'False') = 'False' then
  2034.              dispCut := 0
  2035.           else
  2036.              dispCut := 1;
  2037.           case dispCut of
  2038.           0:Form1.K5.Checked := False;
  2039.           1:Form1.K5.Checked := True;
  2040.           end;
  2041.           { ScrollStep }
  2042.           param := ReadInteger('Scroll', 'Step', -1);
  2043.           if (param < 1) Or (param > 6) then param := 4;
  2044.           step := param;
  2045.           case step of
  2046.           1:Form1.N11.Checked := True;
  2047.           2:Form1.N21.Checked := True;
  2048.           3:Form1.N31.Checked := True;
  2049.           4:Form1.N41.Checked := True;
  2050.           5:Form1.N51.Checked := True;
  2051.           6:Form1.N61.Checked := True;
  2052.           end;
  2053.           { Graphic Disp. }
  2054.           if ReadString('Graphic', 'Show', 'False') = 'False' then
  2055.              picFlag := 0
  2056.           else
  2057.              picFlag := 1;
  2058.           picProg := ReadString('Graphic', 'Program', '');
  2059.           picParam := ReadString('Graphic', 'Dir', '');
  2060.           { Editer Call }
  2061.           if ReadString('Editer', 'Use', 'False') = 'False' then
  2062.              edtFlag := 0
  2063.           else
  2064.              edtFlag := 1;
  2065.           edtProg := ReadString('Editer', 'Program', '');
  2066.           edtParam := ReadString('Editer', 'Dir', '');
  2067.      end;
  2068.      IniFile.Free;
  2069. end;
  2070.  
  2071. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  2072. var
  2073.   IniFile: TIniFile;
  2074.   param: Integer;
  2075.   ini: String;
  2076. begin
  2077.      { Global Block Free }
  2078.      if (isLoad = 1) then
  2079.         GlobalFree(txtHdl);
  2080.  
  2081.      ini := ownPath + 'DC_VIEW.INI';
  2082.      try
  2083.         IniFile := TIniFile.Create(ini);
  2084.         With IniFile do
  2085.         begin
  2086.                { FontSize }
  2087.                if FontSize = 0 then
  2088.                   WriteString('Font', 'FontSize', 'Small')
  2089.                else
  2090.                   WriteString('Font', 'FontSize', 'Large');
  2091.                { CutFile Disp? }
  2092.                if dispCut = 0 then
  2093.                   WriteString('Cut', 'Visible', 'False')
  2094.                else
  2095.                   WriteString('Cut', 'Visible', 'True');
  2096.                { ScrollStep }
  2097.                WriteInteger('Scroll', 'Step', step);
  2098.                { Graphic Disp. }
  2099.                if picFlag = 0 then
  2100.                   WriteString('Graphic', 'Show', 'False')
  2101.                else
  2102.                   WriteString('Graphic', 'Show', 'True');
  2103.                WriteString('Graphic', 'Program', picProg);
  2104.                WriteString('Graphic', 'Dir', picParam);
  2105.                { Editer Call }
  2106.                if edtFlag = 0 then
  2107.                   WriteString('Editer', 'Use', 'False')
  2108.                else
  2109.                   WriteString('Editer', 'Use', 'True');
  2110.                WriteString('Editer', 'Program', edtProg);
  2111.                WriteString('Editer', 'Dir', edtParam);
  2112.           end;
  2113.           IniFile.Free;
  2114.      except
  2115.           on Exception do
  2116.           begin
  2117.              MessageBeep(0);
  2118.              MessageDlg('DC_VIEW.INIを更新することができませんでした。',mtError, [mbOK], 0);
  2119.           end;
  2120.      end;
  2121. end;
  2122.  
  2123. procedure TForm1.H1Click(Sender: TObject);
  2124. begin
  2125.      if (depth = 0) then
  2126.      begin
  2127.            currentFileName := 'DC_VIEW.DOC';
  2128.            loadText(currentFileName);
  2129.            if (dcvError>0) then
  2130.            begin
  2131.                 dcvError := 0;
  2132.                 exit;
  2133.            end;
  2134.            drawText(displine, 0);
  2135.      end
  2136.      else
  2137.      begin
  2138.            { Push CurrentFile }
  2139.            recordFileName[depth] := currentFileName;
  2140.            recorddispline[depth] := displine;
  2141.            recordPath[depth] := currentPath;
  2142.            depth := depth + 1;
  2143.            currentFileName := 'DC_VIEW.DOC';
  2144.  
  2145.            loadText(currentFileName);
  2146.            if (dcvError>0) then
  2147.            begin
  2148.                 dcvError := 0;
  2149.                 returnDoc(0);
  2150.                 exit;
  2151.            end;
  2152.            drawText(displine, 0);
  2153.      end;
  2154. end;
  2155.  
  2156. end.
  2157.